package com.cjj.executor;

import lombok.SneakyThrows;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @ClassName NewCachedThreadPool
 * @Date 2021/07/18 23:52:37
 * @Created by ccc-j
 * @email ccc-ju@outlook.com
 */
public class NewCachedThreadPool {
    public static void main(String[] args) {
        // 创建可缓存线程池
        ExecutorService executorService = Executors.newCachedThreadPool();
        for(int i = 0; i < 30; i++){
            int index = i;
            executorService.execute(new Runnable() {
                @SneakyThrows
                @Override
                public void run() {
//                    Thread.sleep(100);
                    System.out.println(Thread.currentThread().getName() + "----" + index);
                }
            });
        }
    }
}
